package com.baidu.www;
import java.util.Scanner;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int []array=new int[n+1];
        for(int i=0;i<n;i++) {
            array[i]=in.nextInt();
        }
        Arrays.toString(array);
        int p=in.nextInt();
        int i=0;
        for(i=n-1;i>=0;i--) {
            if(array[i]>p) {
                array[i+1]=array[i];
            } else {
                array[i+1]=p;
                break;
            }
        }
        if(i<0) {
            array[0]=p;
        }
        for(i = 0; i <= n; i++) {
            System.out.print(array[i] + " ");
        }
    }
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int []array=new int[n+1];
        for(int i=0;i<n;i++) {
            array[i]=in.nextInt();
        }
        System.out.println(Arrays.toString(array));
        int p=in.nextInt();
        int i=0;
        for( i=0;i<n;i++) {
            if(p<array[i]) {
                for(int j=n;j>i;j--) {
                    array[j]=array[j-1];
                }
                array[i]=p;
            }
        }
        if(i==n) {
            array[i]=p;
        }
        for(i = 0; i <= n; i++) {
            System.out.print(array[i] + " ");
        }
    }

    public static void main1(String[] args) {
        int []array={2,3,4,6,8};
        Arrays.toString(array);
    }
}

